<template>
  <div id="app">
    <keep-alive v-if="isLoggedIn">
      <router-view  v-if="$route.meta.isAlive"></router-view>
    </keep-alive>
    <router-view v-if="!$route.meta.isAlive || !isLoggedIn"></router-view>
  </div>
</template>

<script>
import { getToken } from './utils/token'
export default {
  name: 'App',
  data(){
    return {
      isLoggedIn: false
    }
  },
  watch: {
    $route() {
      let token = getToken()
      if(token) {
        this.isLoggedIn = true
      }else {
        this.isLoggedIn = false
      }
    }
  }
}
</script>

<style>
* {
  margin: 0;
  padding: 0;
}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
  width: 100%;
  height: 100%;
  min-height: 100vh;
}
</style>
